<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>events</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="example-1">
    <button v-on:click="counter+=1">Add 1</button>
    <p>The button above has been clicked {{counter}} times</p>
</div>
<hr>
<div id="example-2">
    <button v-on:click="greet">Greet</button>
</div>
<hr>
<div id="example-3">
    <button v-on:click="say('hi')">Say hi</button>
    <button v-on:click="say('what')">Say what</button>
</div>
<hr>
<div id="example-4">
    <button v-on:click="warn('Form cannot be submitted yet.',$event)">
        Submit
    </button>
</div>
<hr>
</body>
<script type="text/javascript">
    var example1 = new Vue({
        el:'#example-1',
        data:{
            counter : 0
        }
    })

    var example2 = new Vue({
        el:'#example-2',
        data:{
            name: 'Vue.js'
        },
        methods:{
            greet: function(event){
                alert('Hello'+ this.name+'!')
                if(event){
                    alert(event.target.tagName)
                }
            }
        }
    })

    new Vue({
        el:'#example-3',
        methods:{
            say:function(message){
                alert(message)
            }
        }
    })

    var example4 = new Vue({
        el:'#example-4',
        methods:{
            warn:function(message,event){
                if(event){
                    event.preventDefault()
                }
                alert(message)
            }
        }
    })
</script>
</html>